﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyFile
{
    public class Test_Event
    {
        //定义委托
        public delegate void SimpleEventHandler(object sender, EventArgs e);
        //声明事件
        public event SimpleEventHandler SimpleEvent;
        //触发事件方法
        public void OnSimpleEvent(int iii)
        {
            //判断参数
            if (iii == 1)
                OnSimpleEvents(new EventArgs());
        }
        //触发事件
        public void OnSimpleEvents(EventArgs e)
        {
            SimpleEventHandler handler = SimpleEvent;
            if (handler != null)
            {
                handler(this, e);
            }
        }
    }
    public class MyClass
    {
        public void Run()
        {
            Test_Event getData = new Test_Event();
            //注册事件
            getData.SimpleEvent += SimpleGo;
            //传入参数，触发事件
            getData.OnSimpleEvent(int.Parse(Console.ReadLine()));
        }
        //定义事件处理方法
        public static void SimpleGo(object sender, EventArgs e)
        {
            Console.WriteLine("SimpleGo");
        }
    }
}
